Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nv2a: add new NV_PGRAPH parameters, fix W_param tests, ZMinMaxControl tests, see through and missing shadows #1895

Open
wants to merge 30 commits into
base: master
Choose a base branch
from

Conversation

polymetal0
Copy link

@polymetal0 polymetal0 commented Feb 4, 2025

I have reuploaded this PR because renaming my fork's branch automatically closed the other one.

RECAP

  • Added NV_PGRAPH_CONTROL_3_TEXTURE_PERSPECTIVE_ENABLE and NV_PGRAPH_ZCOMPRESSOCCLUDE_CULL_NEAR_FAR_EN
  • Removed vtx_inv_w and vtx_inv_w_flat
  • Implement clipping and [-1, 1] clip volume change for ogl from frag shader
  • Added depth buffer shader variable to store w coordinate
  • Apply zbias to w buffer

Fixes/shows progress (captures taken in Vulkan, 2x)
W_param tests
https://github.com/abaire/nxdk_pgraph_tests_golden_results/tree/main/W_param
PR
w_gaps
xemu-2025-01-11-23-13-46
w_neg_strip
xemu-2025-01-11-23-13-50
w_pos_strip (fixed)
xemu-2025-01-11-23-14-04

ZMinMaxControl tests
https://github.com/abaire/nxdk_pgraph_tests_golden_results/tree/main/ZMinMaxControl
PR
Ctrl_NEARFAR_ZCLAMP
Ctrl_NEARFAR_ZCLAMP_IgnW
Ctrl_NEARFAR_ZCULL
Ctrl_NEARFAR_ZCULL_IgnW
Ctrl_WBuf_NEARFAR_ZCLAMP
Ctrl_WBuf_NEARFAR_ZCLAMP_IgnW
Ctrl_WBuf_NEARFAR_ZCULL
Ctrl_WBuf_NEARFAR_ZCULL_IgnW
Ctrl_WBuf_ZCLAMP
Ctrl_WBuf_ZCLAMP_IgnW
Ctrl_WBuf_ZCULL
Ctrl_WBuf_ZCULL_IgnW
Ctrl_ZCLAMP
Ctrl_ZCLAMP_IgnW
Ctrl_ZCULL
Ctrl_ZCULL_IgnW
CtrlFixed_NEARFAR_ZCLAMP
CtrlFixed_NEARFAR_ZCLAMP_IgnW
CtrlFixed_NEARFAR_ZCULL
CtrlFixed_NEARFAR_ZCULL_IgnW
CtrlFixed_WBuf_NEARFAR_ZCLAMP
CtrlFixed_WBuf_NEARFAR_ZCLAMP_IgnW
CtrlFixed_WBuf_NEARFAR_ZCULL
CtrlFixed_WBuf_NEARFAR_ZCULL_IgnW
CtrlFixed_WBuf_ZCLAMP
CtrlFixed_WBuf_ZCLAMP_IgnW
CtrlFixed_WBuf_ZCULL
CtrlFixed_WBuf_ZCULL_IgnW
CtrlFixed_ZCLAMP
CtrlFixed_ZCLAMP_IgnW
CtrlFixed_ZCULL
CtrlFixed_ZCULL_IgnW

Comments: clipping planes match HW behavior at 1x but are a bit off at higher scales (most likely unrelated). Near/far custom clipping planes are incorrect; they're hardcoded to test behavior and to approach HW results. OGL shows erratic behavior when running fixed function tests specifically, as shown here (fixed in the latest commit)

I'm leaving it here. "NEARFAR" feature is implemented but not fixed, left some comments in the code. I'll fix it in another PR if I find a solution, or let someone else beat me to it

Passing clipRange variable as a uniform and performing perspective divide in fragment shader for z_perspective = true solves the see through issue that affects many games.

Shader code for z_perspective = false is virtually unaltered.
They are still there, but unused
- z_perspective refactor to PixelShader and texture_perspective var added
- vtx_inv_w and vtx_inv_w_flat vars totally removed
- Fixes warping of textures from previous commit w/o breaking tests
- Also fixes dashboard menu background regression
This reverts commit 4da74db.
- Regression of some fixed missing shadows from xemu-project#577, identified the source of the problem
Restores shadows for many games in xemu-project#577 w/o removing the Xbox dashboard background
Do not specify cull mode if NV_PGRAPH_SETUPRASTER_CULLENABLE = false
Partially fixes fixed function, w-buffer, z cull tests
- Discard fragments from shader
- Implemented zbias when w-buffering
- Clipping volume change to [-1 , 1] for OGL moved to frag shader to avoid floating point precission loss
- Added parameter NV097_SET_ZMIN_MAX_CONTROL_CULL_NEAR_FAR_EN_TRUE
- Added depth buffer variable to shaders to store w coordinate
- They are there just to test behavior and most likely incorrect, but close enough to HW. It's a good starting point for future work
- Fixed texture perspective issue in fixed function
@crashGG
Copy link

crashGG commented Feb 4, 2025

You really scared me. I thought such a good PR was closed because there was no response for a long time...

- This fixes OGL not refreshing display properly when running some tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants